var cityCode = '';
var cityName = '';
$(function() {
	//rem兼容使用
	document.documentElement.style.fontSize = window.innerWidth/3.75 + 'px';
	$(window).on('resize',function() {
		document.documentElement.style.fontSize = window.innerWidth/3.75 + 'px';
	});
	
	
	
	if(isIOS()) {
		
		//ios操作
		
		
	}
	else {
		//android操作
		
		cityCode = JavascriptInterface.getCityCode();
		cityName = JavascriptInterface.getCityName();
		$(".cityP").text(cityName);
		getAllFeesDatas(cityCode);
		
	}
	
	
	
	
})


function getCityCode(aa){	
	cityCode = aa;	
	getAllFeesDatas(cityCode);
}

function getCityName(bb){	
	cityName = bb;		
	$(".cityP").text(cityName);
}

//获取城市相关计费规则数据
function getAllFeesDatas(cityNo) {
	$.ajax({
		type: "POST",
		//url: "http://192.168.1.21:8091/dingding-web/cityAction!getSpecialChargingRules",//上线要改地址
		url: "http://test.pdhz-dddc.com/dingding-web/cityAction!getSpecialChargingRules",//测试
		//url: "http://www.pdhz-dddc.cn/dingding-web/cityAction!getSpecialChargingRules",//正式
		dataType: "jsonp",	
		async: false,
		jsonp: "callback",
		jsonpCallback: "success_jsop",
		data: {
			cityNo: cityNo
		},
		success: function(data) {
			console.log(data);
			if(data.code == 200) {
				$.each(data.responseBody, function(k,v) {
					if(v.vehicleLevel == 1) {//经济型
						console.log(v.durationFee);
						$('.car1fee1td').text(v.minimums + '元');              //起步费
						$('.car1fee2td').text(v.durationFee + '元/公里');      //时长费
						$('.car1fee3td').text(v.mileageFee + '元/公里');       //里程费
						$('.car1fee4td').text(v.longFee + '元/公里');          //远途费
						$('.car1fee5td').text(v.nightFee + '元/公里');         //夜间费
						$('.longStartFee').text("当里程超过" + v.longStartMileage + "公里后加收");
						$('.nightduring').text("夜间("+v.nightStart+"--次日"+v.nightEnd+")行驶加收");
					}
					if(v.vehicleLevel == 2) {//舒适型
						console.log(v.durationFee);
						$('.car2fee1td').text(v.minimums + '元');              //起步费
						$('.car2fee2td').text(v.durationFee + '元/公里');      //时长费
						$('.car2fee3td').text(v.mileageFee + '元/公里');       //里程费
						$('.car2fee4td').text(v.longFee + '元/公里');          //远途费
						$('.car2fee5td').text(v.nightFee + '元/公里');         //夜间费
						$('.longStartFee').text("当里程超过" + v.longStartMileage + "公里后加收");
						$('.nightduring').text("夜间("+v.nightStart+"--次日"+v.nightEnd+")行驶加收");
					}
					if(v.vehicleLevel == 3) {//商务型
						console.log(v.durationFee);
						$('.car3fee1td').text(v.minimums + '元');              //起步费
						$('.car3fee2td').text(v.durationFee + '元/公里');      //时长费
						$('.car3fee3td').text(v.mileageFee + '元/公里');       //里程费
						$('.car3fee4td').text(v.longFee + '元/公里');          //远途费
						$('.car3fee5td').text(v.nightFee + '元/公里');         //夜间费
						$('.longStartFee').text("当里程超过" + v.longStartMileage + "公里后加收");
						$('.nightduring').text("夜间("+v.nightStart+"--次日"+v.nightEnd+")行驶加收");
					}
					if(v.vehicleLevel == 4) {//豪华型
						console.log(v.durationFee);
						$('.car4fee1td').text(v.minimums + '元');              //起步费
						$('.car4fee2td').text(v.durationFee + '元/公里');      //时长费
						$('.car4fee3td').text(v.mileageFee + '元/公里');       //里程费
						$('.car4fee4td').text(v.longFee + '元/公里');          //远途费
						$('.car4fee5td').text(v.nightFee + '元/公里');         //夜间费
						$('.longStartFee').text("当里程超过" + v.longStartMileage + "公里后加收");
						$('.nightduring').text("夜间("+v.nightStart+"--次日"+v.nightEnd+")行驶加收");
					}
				});
			}
			else {
				layer.open({
					content: data.errorMessage,
					style: 'font-family: 微软雅黑;',
					skin: 'msg',
					time: 2,
					fixed: false,
					top: -300	
				});
			}
		}
	});
}
